package com.site.dao;

import com.site.common.DbHelper;
import com.site.entity.HeadOtherEntity;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;

public class HeadOtherDao extends DbHelper {
    //得到所有的其他标题
    public HeadOtherDao() throws ClassNotFoundException, SQLException{

    }

    public List<HeadOtherEntity> getAll() throws SQLException{
        ResultSet rs=query("select * from tbheadother");
        List<HeadOtherEntity> list=new ArrayList<HeadOtherEntity>();
        while (rs.next()){
            list.add(getEntity(rs));
        }

        rs.close();
        close();
        return list;
    }

    private HeadOtherEntity getEntity(ResultSet rs) throws SQLException{
        HeadOtherEntity entity=new HeadOtherEntity();
        entity.setTitle(rs.getString("title"));
        entity.setSource(rs.getString("source"));
        return entity;
    }
}
